package com.vaadin.incubator.bugrap.tests.model;

import java.util.Date;

import org.junit.Test;

import com.vaadin.incubator.bugrap.model.facade.FacadeUtil;
import com.vaadin.incubator.bugrap.model.reports.Comment;
import com.vaadin.incubator.bugrap.model.reports.CommentType;
import com.vaadin.incubator.bugrap.model.reports.Report;
import com.vaadin.incubator.bugrap.model.users.Reporter;

public class CommentTest extends TestBase {

	@Test
	public void testGetAuthor() {
		Reporter r = new Reporter();
		r = FacadeUtil.store(r);

		Comment c = new Comment();
		c.setReport(new Report());
		c.setAuthor(r);
		c = FacadeUtil.store(c);
		assertEquals(r, c.getAuthor());
	}

	@Test
	public void testSetAuthor() {
		Reporter r = new Reporter();
		r = FacadeUtil.store(r);

		Comment c = new Comment();
		c.setReport(new Report());
		c.setAuthor(r);
		c = FacadeUtil.store(c);
		assertEquals(r, c.getAuthor());
	}

	@Test
	public void testGetComment() {
		Comment c = new Comment();
		c.setComment("comment");
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals("comment", c.getComment());
	}

	@Test
	public void testSetComment() {
		Comment c = new Comment();
		c.setComment("comment");
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals("comment", c.getComment());
	}

	@Test
	public void testGetTimestamp() {
		Comment c = new Comment();
		Date d = new Date();
		c.setTimestamp(d);
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals(d, c.getTimestamp());
	}

	@Test
	public void testSetTimestamp() {
		Comment c = new Comment();
		Date d = new Date();
		c.setTimestamp(d);
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals(d, c.getTimestamp());
	}

	@Test
	public void testGetAttachment() {
		Comment c = new Comment();
		byte[] a = "Test".getBytes();
		c.setAttachment(a);
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals(a, c.getAttachment());
	}

	@Test
	public void testSetAttachment() {
		Comment c = new Comment();
		byte[] a = "Test".getBytes();
		c.setAttachment(a);
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals(a, c.getAttachment());
	}

	@Test
	public void testGetType() {
		Comment c = new Comment();
		c.setType(CommentType.ATTACHMENT);
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals(CommentType.ATTACHMENT, c.getType());
	}

	@Test
	public void testSetType() {
		Comment c = new Comment();
		c.setType(CommentType.ATTACHMENT);
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals(CommentType.ATTACHMENT, c.getType());
	}

	@Test
	public void testGetAttachmentName() {
		Comment c = new Comment();
		c.setAttachmentName("aaaa");
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals("aaaa", c.getAttachmentName());
	}

	@Test
	public void testSetAttachmentName() {
		Comment c = new Comment();
		c.setAttachmentName("aaaa");
		c.setReport(new Report());
		c = FacadeUtil.store(c);
		assertEquals("aaaa", c.getAttachmentName());
	}

}
